package cn.tedu.day01.ssm.controller;

import cn.tedu.day01.ssm.pojo.Emp;
import cn.tedu.day01.ssm.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/emp")
@CrossOrigin // 实现跨域功能
public class EmpController {
    @Autowired
    private EmpService empService;
    @RequestMapping("/findAll")
    public List<Emp> findAllEmp(){
        return empService.queryAllEmps();
    }
    @RequestMapping("/addEmp")
    public String addEmps(@RequestBody  Emp emp){
       int row =  empService.insertEmp(emp);
       if (row>0){
           return "插入成功";
       }
        return "插入失败";

    }


}
